define(function(require,exports,module){
	
	require('/plugins/echarts/echarts-plain-original');
	//提示效果
    require.async(['/plugins/poshytip/tip-yellowsimple/tip-yellowsimple.css','/plugins/poshytip/jquery.poshytip.min'],function(){
    	$('.textTips').poshytip({
    		className: 'tip-yellowsimple',
    		showTimeout: 1,
    		alignTo: 'target',
				alignX: 'center',
				alignY: 'top',
				offsetY: 10,
    		allowTipHover:false
    	});
	});
	
	//初始化加载表
	ajaxDate($("#collectInterestSelect").val());
	ajaxDate1($("#collectPrincipalSelect").val());
	
	
	$("#collectInterestSelect").change(function(){
        var nowData1 =$(this).val();
        ajaxDate(nowData1);
    });
	
	$("#collectPrincipalSelect").change(function(){
        var nowData2 =$(this).val();
        ajaxDate1(nowData2);
    });
	
	function ajaxDate(param){
		//待收利息表
		$.ajax({
			url:"/member/account/interestJson.html?date=" + param + "&randomTime=" + (new Date()).getTime(),
			type:"get",
			dataType:"json",
			success:function(data){
				// 基于准备好的dom，初始化echarts图表
		        var myChart = echarts.init(document.getElementById('collectInterest')); 
		        var option = {
		        	    tooltip : {
		        	        trigger: 'axis',
		        	        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
		        	            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
		        	        }
		        	    },
		        	    legend: {
		        	        data:['待收利息','加息券待收利息'],
		        	        x:'right',
		        	        y:'bottom'
		        	    },
		        	    toolbox: {
		        	        show : true,
		        	        orient: 'vertical',
		        	        x: 'right',
		        	        y: 'center',
		        	        feature : {
		        	            mark : false,
		        	            dataView : {readOnly: false},
		        	            magicType:['line', 'bar'],
		        	            restore : false,
		        	            saveAsImage : false
		        	        }
		        	    },
		        	    calculable : false,
		        	    xAxis : [
		        	        {
		        	            type : 'category',
		        	            data : data.day
		        	        }
		        	    ],

		        	    yAxis : [
		        	        {
		        	            type : 'value',
		        	            splitArea : {show : false}
		        	        }
		        	    ],

		        	    series : [
		        	        {
		        	            name:'待收利息',
		        	            type:'bar',
		        	           stack: '待收',
		        	            data:data.value
		        	        },		        	     
		        	        {
		        	            name:'加息券待收利息',
		        	            type:'bar',
		        	           stack: '待收',
		        	            data:data.rateValues
		        	        }
		        	    ]
		        };
		        // 为echarts对象加载数据 
		        myChart.setOption(option);
			}
		});
		}
		
	function ajaxDate1(param){ 
        //待收本金表
        // 基于准备好的dom，初始化echarts图表
		$.ajax({
			url:"/member/account/capitalJson.html?date=" + param + "&randomTime=" + (new Date()).getTime(),
			type:"get",
			dataType:"json",
			success:function(data){
				
				var myChart = echarts.init(document.getElementById('collectPrincipal')); 
		        var option = {
		        	    tooltip : {
		        	        trigger: 'axis',
		        	        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
		        	            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
		        	        }
		        	    },
		        	    legend: {
		        	        data:['待收本金'],
		        	        x:'right',
		        	        y:'bottom'
		        	    },
		        	    toolbox: {
		        	        show : true,
		        	        orient: 'vertical',
		        	        x: 'right',
		        	        y: 'center',
		        	        feature : {
		        	            mark : true,
		        	            dataView : {readOnly: false},
		        	            magicType:['line', 'bar'],
		        	            restore : false,
		        	            saveAsImage : false
		        	        }
		        	    },
		        	    calculable : false,
		        	    xAxis : [
		        	        {
		        	            type : 'category',
		        	            data : data.day
		        	        }
		        	    ],

		        	    yAxis : [
		        	        {
		        	            type : 'value',
		        	            splitArea : {show : false}
		        	        }
		        	    ],

		        	    series : [
		        	        {
		        	            name:'待收本金',
		        	            type:'bar',
		        	           stack: '待收',
		        	            data:data.value
		        	        }
		        	    ]
		        };
		        // 为echarts对象加载数据 
		        myChart.setOption(option); 
			}
		});
	}  
});